package com.yeheng.converts;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @PackgeName: com.yeheng.converts
 * @ClassName: MyConvert
 * @Author: YH
 * Date: 2021/1/1 14:32
 * project name: homework1
 * @Version:
 * @Description:
 */
public class MyConvert implements Converter<String,Date> {

    @Override
    public Date convert(String s) {
        try{
            Date date = new SimpleDateFormat("yyyy-MM-dd").parse(s);
            return date;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}
